package com.zys.mappers;

import com.zys.pojo.dto.SelectUserByUsernameAndPassword;
import com.zys.pojo.entity.GxaUser;
import com.zys.zys_mybatis.Insert;
import com.zys.zys_mybatis.Param;
import com.zys.zys_mybatis.Select;

import java.util.List;

public interface GxaUserMapper {

    /**
     * 根据id查询用户信息
     * @param id
     * @return  GxaUser
     */
    @Select(value = "select * from gxa_user where id = #{id}")
    public GxaUser getUserById(@Param("id") Integer id);

    /**
     * 根据用户名查询用户信息
     * @param username
     * @return  GxaUser
     */
    @Select(value = "select * from gxa_user where username = #{username} and id = #{id}")
    public GxaUser getUserByUsername(@Param("username") String username, @Param("id") Integer id);

    /**
     * 查询所有用户信息
     *
     * @return  List<GxaUser>
     */
    @Select(value = "select * from gxa_user")
    public List<GxaUser> getAllUser();

    /**
     * 根据用户名和密码查询用户
     *
     * @param selectUserByUsernameAndPassword
     * @return  GxaUser
     */
    @Select(value = "select * from gxa_user where username = #{username} and password = #{password}")
    public GxaUser SelectUserByUsernameAndPassword(SelectUserByUsernameAndPassword selectUserByUsernameAndPassword);

    /**
     * 新增一条用户
     *
     * @param gxaUser
     * @return  int
     */
    @Insert(value = "insert into gxa_user(username,password,salt,phone,created,last_login_time,status) " +
            "values(#{username},#{password},#{salt},#{phone},#{created},#{lastLoginTime},#{status})")
    public int insertUser(GxaUser gxaUser);

    /**
     * 通过id删除用户
     *
     * @param id
     * @return  int
     */
    @Insert(value = "delete from gxa_user where id = #{id}")
    public int deleteUserById(@Param("id") Integer id);
}
